#include<bits/stdc++.h>
using namespace std;
const long long N=1e5+5;
struct node{
	long long d,v,a;
}g[N];
long long p[N];
inline long long read();
inline void subtaskA(long long n,long long m,long long L,long long V){
	long long ans1=0,ans2=0;
	for(long long i=1;i<=n;++i){
		if(g[i].v>V&&g[i].d<=p[m])ans1++;
	}
	if(ans1==0)ans2=m;
	else ans2=m-1;
	printf("%lld %lld\n",ans1,ans2);
}
inline void subtaskB(long long n,long long m,long long L,long long V){
	long long ans1=0,ans2=0;
	for(long long i=1;i<=n;++i){
		if(g[i].d>p[m])continue;
		long long v=g[i].v*g[i].v+2*g[i].a*(p[m]-g[i].d);
		if(v>V*V){
			ans1++;
		}
	}
	if(ans1==0)ans2=m;
	else ans2=m-1;
	printf("%lld %lld\n",ans1,ans2);
}
double ed[N];
bool vis[N];
inline void subtaskC(long long n,long long m,long long L,long long V){
	long long ans1=0,ans2=0;
	for(long long i=1;i<=n;++i){
		if(g[i].v<=V)continue;
		ed[i]=g[i].d*1.0+(V*V-g[i].v*g[i].v)*1.0/(2*g[i].a);
		int left=lower_bound(p+1,p+m+1,g[i].d)-p-1;
		for(long long j=max(left-1,0);j<=m;++j){
			if(p[j]>=g[i].d&&p[j]*1.0<ed[i]){
				ans1++;
				break;
			}
			if(p[j]*1.0>=ed[i])break;
		}
	}
	printf("%lld %lld\n",ans1,ans2);
}
inline void work(long long n,long long m,long long L,long long V){
	long long ans1=0,ans2=0;
	for(long long i=1;i<=n;++i){
		if(g[i].a==0){
			if(g[i].v>V&&g[i].d<=p[m]){
				ans1++;
				vis[i]=1;
			}
			ed[i]=L;
		}else if(g[i].a>0){
			ed[i]=L;
			if(g[i].d>p[m])continue;
			long long v=g[i].v*g[i].v+2*g[i].a*(p[m]-g[i].d);
			if(v>V*V){
				ans1++;
				vis[i]=1;
			}
		}else{
			ed[i]=g[i].d;
			if(g[i].v<=V)continue;
			ed[i]=g[i].d*1.0+(V*V-g[i].v*g[i].v)*1.0/(2*g[i].a);
			int left=lower_bound(p+1,p+m+1,g[i].d)-p-1;
			for(long long j=max(left-1,0);j<=m;++j){
				if(p[j]>=g[i].d&&p[j]*1.0<ed[i]){
					ans1++;
					vis[i]=1;
					break;
				}
				if(p[j]*1.0>=ed[i])break;
			}
		}
	}
	for(long long i=0;i<=(1<<m)-1;++i){
		for(long long j=1;j<=m;++j){
			
		}
	}
	printf("%lld %lld\n",ans1,ans2);
}
inline void solve(){
	long long n=read(),m=read(),L=read(),V=read();
	bool flagA=0,flagB=0,flagC=0;
	for(long long i=1;i<=n;++i){
		long long d=read(),v=read(),a=read();
		g[i]={d,v,a};
		if(a!=0)flagA=1;
		if(a<=0)flagB=1;
		if(a>=0)flagC=1;
		vis[i]=0;
	}	
	for(long long i=1;i<=m;++i){
		p[i]=read()
	}
	if(flagA==0){
		subtaskA(n,m,L,V);
	}else if(flagB==0){
		subtaskB(n,m,L,V);
	}else if(flagC==0){
		subtaskC(n,m,L,V);
	}else{
		work(n,m,L,V);
	}
}
signed main(){
	freopen("detect1.in","r",stdin);
	freopen("detect.out","w",stdout);
//	long long T=1;
	long long T=read();
	while(T--)solve();
	return 0;
}
inline long long read(){
	long long x;scanf("%lld",&x);
	return x;
}
